﻿namespace TetrisProject
{
    using System;
    using System.Collections.Generic;
    using System.Threading;
    using TetrisProject.GameObjects;
    using TetrisProject.GameObjects.Blocks;
    using TetrisProject.Interfaces;

    public class ProgramMain
    {
        private const int WIDTH = 80;
        private const int HEIGHT = 20;

        public static void Main(string[] args)
        {
            Console.CursorVisible = false;
            Console.BufferHeight = Console.WindowHeight = ProgramMain.HEIGHT;
            Console.BufferWidth = Console.WindowWidth = ProgramMain.WIDTH;

            var keyboard = new Keyboard();
            var engine = new Engine(ProgramMain.HEIGHT, ProgramMain.WIDTH, keyboard);

            keyboard.ArrowPressed += (sender, e) =>
            {
                var arrowPressed = (sender as Keyboard).PressedKey.Key;
                engine.OnArrowPressed(arrowPressed);
            };

            keyboard.SpacePressed += (sender, e) =>
            {
                engine.OnSpacePressed();
            };

            engine.Run();
        }
    }
}
